<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>终端型号名称：</p>
                                <input type="text" name="terminalTypeName"/>
                            </li>
                            <li>
                                <p>终端型号编号：</p>
                                <input type="text" name="terminalTypeNumber"/>
                            </li>
                            <li>
                                <p>终端种类：</p>
                                <select name="terminalKind">
                                    <option value="">请选择终端种类</option>
                                    <option value="车机">车机</option>
                                    <option value="T-Box">T-Box</option>
                                    <option value="OBD">OBD</option>
                                    <option value="智能后视镜">智能后视镜</option>
                                    <option value="智能行车记录仪">智能行车记录仪</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                        </div>
                        <div class="modal-body">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">工作电压：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="workingVoltage" class="form-control" placeholder="请输入文本">V
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">固件版本号：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="firmwareName" class="form-control" placeholder="请输入文本">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">功耗：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="powerDissipation" class="form-control" placeholder="请输入文本">kWh
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">休眠电流：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="dormantElectricity" class="form-control" placeholder="请输入文本">mA
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">内置电池容量：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="batteryCapacity" class="form-control" placeholder="请输入文本">Ah
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:type:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:type:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:type:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:type:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <script th:inline="javascript">
         function toFind(id){
             $.ajax({
                 url:prefix + "/toFind",
                 type:"get",
                 data:{ttid:id},
                 datatype:"json",
                 success:function (data) {
                     console.log(data);
                     $("[name = 'workingVoltage']").val(data.workingVoltage);
                     $("[name = 'firmwareName']").val(data.firmwareName);
                     $("[name = 'powerDissipation']").val(data.powerDissipation);
                     $("[name = 'dormantElectricity']").val(data.dormantElectricity);
                     $("[name = 'batteryCapacity']").val(data.batteryCapacity);
                 }
             })
         }
     </script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:type:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:type:remove')}]];
        var prefix = ctx + "system/type";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'ttid',
                    title : '终端型号ID主键',
                    visible: false
                },
                {
                    field : 'terminalTypeName',
                    title : '终端型号名称'
                },
                {
                    field : 'terminalTypeNumber',
                    title : '终端型号编号'
                },
                {
                    field : 'terminalKind',
                    title : '终端种类'
                },
                {
                    field : 'terminalBrand',
                    title : '终端品牌'
                },
                {
                    title: '车载终端性能参数',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a  data-toggle="modal" data-target="#myModal" onclick="toFind(\'' + row.ttid + '\')">查看详细信息</a> ');
                        return actions.join('');
                    }
                },
                {
                    field : 'manufacturerName',
                    title : '生产厂商名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ttid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ttid + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>
